--[[/**
-- * 
 * 幸运之盾, 敌人身上如果有某个效果
 * 揍我时减免伤害
-- */]]

---@class BuffEffect64100 : BaseBuffEffect
BuffEffect64100 = ClientFight.CreateClass("BuffEffect64100", ClientFight.BaseBuffEffect)
local t = BuffEffect64100

---@param fight Fight
---@param buff FighterBuff
function t:action(fight, buff, ...)
 local parameters = {...};
 if (parameters[1])then
  else 
 return IBuffEffect.FAIL;
 end
 if (parameters[3])then
  else 
 return IBuffEffect.FAIL;
 end
 local result =parameters[3];
 if (not result:isDamage())then
 return IBuffEffect.FAIL;
 end
 if (not AttackUtils.isDamage(result.state)) then
 return IBuffEffect.FAIL;
 end
 local attacker = parameters[1];
 local o = attacker.parametersByObject[BuffEffect64101.BuffEffect64101];
 if (o == nil) then
 return IBuffEffect.FAIL;
 end
local debuffSets = o;
 if (debuffSets.isEmpty()) then
 return IBuffEffect.FAIL;
 end
 local debuffCount = table.getn(debuffSets);
 local i = debuffCount * buff.buffBean.f_BuffEffectValue[1];
 local reduceDamage = Utils.calcRatio(result.damage, i);
 if (reduceDamage == 0) then
 return IBuffEffect.FAIL;
 end
 local damage = result.damage;
 result.setDamage(damage + reduceDamage);
 SkillRoleMgr.savePathFile(string.format("[%s][EFFECT]Fighter:%s Buff:%s 幸运之盾效果触发, 减免万分之:%s , 原伤害:%s , 减免伤害: %s",
 fight.frame, buff.target.fighterId, buff.modelId,i,damage,reduceDamage));

    return ClientFight.BaseBuffEffect.action(self, fight, buff, ...);
end

t.New()